﻿using System;
using System.Collections.Generic;
using System.Text;

namespace GoalParserInterpretation
{
    public class Solution
    {
        public string Interpret(string command)
        {
            var stack = new Stack<char>();
            var sb = new StringBuilder();
            foreach (var c in command)
            {
                switch (c)
                {
                    case 'G':
                        sb.Append(c);
                        break;
                    case ')':
                        stack.Pop();
                        if (stack.Count > 0)
                        {
                            sb.Append("al");
                            stack.Clear();
                        }
                        else
                        {
                            sb.Append('o');
                        }
                        break;
                    default:
                        stack.Push(c);
                        break;
                }
            }
            return sb.ToString();
        }
    }
}
